<template>
  <div class="app-container">
    <eHeader :param-bean="paramBean" :sup_this="sup_this" />
    <eForm ref="form" :sup_this="sup_this" />
    <historyList ref="historyList" :sup_this="sup_this" />
    <!--表格渲染-->
    <DataGridTable
      v-loading="loading"
      ref="mainTable"
      :sup_this="sup_this"
      :data="data.rtnList"
      :max-height="gridMaxHeight"
      :total="total"
      :show-cell-class="true"
      :show-row-complex-number="true"
      :all-define-columns="['busDate','sysOrgName','busOtherCpyName','selfStateName','invoiceByName','cashByName','invoiceNo','billType','customCerCode','customName','customAddress','customBankNo','customBankName','saleCerCode','saleName','saleAddress','saleBankNo','saleBankName','column22','lastUpdateDate',]"
      grid-id="finInvoiceMngProcessGridId"
      @toViewHistory="toViewHistory"
      @selection-change="handleGridSelectionChange">
      <DataGridColumnSlot prop="sysGenCode" label="业务类型">
        <template slot-scope="scope">
          <edit :data="scope.row" :sup_this="sup_this" />
        </template>
      </DataGridColumnSlot>
      <DataGridColumnSlot slot="busDate" prop="busDate" label="业务时间">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.busDate) }}</span>
        </template>
      </DataGridColumnSlot>
      <DataGridColumn slot="sysOrgName" prop="sysOrgName" label="机构" />
      <DataGridColumn slot="busOtherCpyName" prop="busOtherCpyName" label="客户"/>
      <DataGridColumn slot="selfStateName" prop="selfStateName" label="状态"/>
      <DataGridColumnSlot slot="invoiceType" prop="invoiceType" label="发票类型">
        <template slot-scope="scope">
          <template v-for="item in dicts.bus_invoice_type">
            <span v-if="scope.row.invoiceType === item.dictCode" :key="item.id" >{{ item.dictName }}</span>
          </template>
        </template>
      </DataGridColumnSlot>
      <DataGridColumn slot="invoiceByName" prop="invoiceByName" label="开票人" />
      <DataGridColumn slot="cashByName" prop="cashByName" label="收款人" />
      <DataGridColumn slot="invoiceNo" prop="invoiceNo" label="发票号" />
      <DataGridColumnSlot slot="billType" prop="billType" label="类别">
        <template slot-scope="scope">
          <template v-for="item in dicts.invoice_bill_type">
            <el-tag v-if="scope.row.billType === item.dictCode" :key="item.id" :type="item.attribute1" >{{ item.dictName }}</el-tag>
          </template>
        </template>
      </DataGridColumnSlot>
      <DataGridColumn slot="customCerCode" prop="customCerCode" label="购方识别号" />
      <DataGridColumn slot="customName" prop="customName" label="购方名称" />
      <DataGridColumn slot="customAddress" prop="customAddress" label="购方地址" />
      <DataGridColumn slot="customBankNo" prop="customBankNo" label="购方银行帐号" />
      <DataGridColumn slot="customBankName" prop="customBankName" label="购方开户银行名称" />
      <DataGridColumn slot="saleCerCode" prop="saleCerCode" label="销方单位识别号" />
      <DataGridColumn slot="saleName" prop="saleName" label="销方名称" />
      <DataGridColumn slot="saleAddress" prop="saleAddress" label="销方地址" />
      <DataGridColumn slot="saleBankNo" prop="saleBankNo" label="销方银行帐号" />
      <DataGridColumn slot="saleBankName" prop="saleBankName" label="销方开户银行名称" />
      <DataGridColumnSlot slot="lastUpdateDate" prop="lastUpdateDate" label="最后更新时间" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastUpdateDate) }}</span>
        </template>
      </DataGridColumnSlot>
    </DataGridTable>
  </div>
</template>

<script>
import { parseTime } from '@/utils/index'
import eHeader from './module/header'
import edit from './module/edit'
import eForm from './module/form'
import historyList from './module/historyList'
import initData from '@/mixins/initData'
import finInvoice from '@/api/fin/FinInvoice'

export default {
  components: { eHeader, eForm, edit, historyList },
  dictTypes: ['invoice_bill_type', 'bus_invoice_type'],
  mixins: [initData],
  props: {
  },
  data() {
    return {
      delLoading: false,
      sup_this: this
    }
  },
  created() {
    this.url = finInvoice.loadDataUrl()
    this.searchToggle = true
    this.$nextTick(() => {
      this.resetQuery(true)
    })
  },
  mounted() {
  },
  methods: {
    parseTime,
    toViewHistory(row) {
      this.openViewHistory(row, 'historyList')
    },
    async beforeInit() {
      return true
    }
  }
}
</script>
